'\" te
.\"  Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved
.\"  Copyright (c) 2012 Joyent, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH HOOK_T 9S "Mar 5, 2012"
.SH NAME
hook_t \- callback structure for subscribing to netinfo events
.SH SYNOPSIS
.nf
#include <sys/hook.h>
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH DESCRIPTION
The \fBhook_t\fR data structure defines a callback that is to be inserted into
a networking event. This data structure must be allocated with a call to
\fBhook_alloc()\fR and released with a call to \fBhook_free()\fR.
.SH STRUCTURE MEMBERS
.in +2
.nf
hook_func_t  h_func;      /* callback function to invoke */
char         *h_name;     /* unique name given to the hook */
int          h_flags;
hook_hint_t  h_hint;      /* insertion hint type */
uintptr_t    h_hintvalue; /* used with h_hint */
void         *h_arg;      /* value to pass into h_func */

typedef int (*hook_func_t)(net_event_t token, hook_data_t info,
              void *);
.fi
.in -2

.SS "CALLBACK RETURN VALUES"
The value returned by the \fBhook_func_t\fR function indicates whether or not
the packet should still be considered valid. If the callback function has
modified the packet in such a way that it should no longer be processed or
considered valid, e.g. called \fBfreemsg\fR(9F), then the callback should return
\fB1\fR. Otherwise it should return \fB0\fR.
.sp

.SS "HINT TYPES"
Hook hints are hints that are used at the time of insertion and are not rules
that enforce where a hook lives for its entire lifetime on an event. The valid
values for the \fBh_hint\fR field are:
.sp
.ne 2
.na
\fB\fBHH_NONE\fR\fR
.ad
.RS 13n
Insert the hook wherever convenient.
.RE

.sp
.ne 2
.na
\fB\fBHH_FIRST\fR\fR
.ad
.RS 13n
Place the hook first on the list of hooks.
.RE

.sp
.ne 2
.na
\fB\fBHH_LAST\fR\fR
.ad
.RS 13n
Place the hook last on the list of hooks.
.RE

.sp
.ne 2
.na
\fB\fBHH_BEFORE\fR\fR
.ad
.RS 13n
Place the hook before another hook on the list of hooks. The value in
\fBh_hintvalue\fR must be a pointer to the name of another hook.
.RE

.sp
.ne 2
.na
\fB\fBHH_AFTER\fR\fR
.ad
.RS 13n
Place the hook after another hook on the list of hooks. The value in
\fBh_hintvalue\fR must be a pointer to the name of another hook.
.RE

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
.TE

.SH SEE ALSO
.BR netinfo (9F)
